/**
 *  This file is part of AugeasWH.
 *
 *  AugeasWH. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AugeasWH. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AugeasWH.  If not, see <http://www.gnu.org/licenses/>.
 */

package cz.fit.vutbr.pis2012.augeaswh.persistence;

import java.io.Serializable;
import javax.persistence.*;

/**
 * The primary key class for the contacts_subjects database table.
 * 
 */
@Embeddable
public class ContactsSubjectPK implements Serializable, AugeasWHEntity {
	//default serial version id, required for serializable classes.
	private static final long serialVersionUID = 1L;

	@Column(name="subject_id")
	private Long subjectId;

	@Column(name="contact_id")
	private Long contactId;

	private String relation;

    public ContactsSubjectPK() {
    }
	public Long getSubjectId() {
		return this.subjectId;
	}
	public void setSubjectId(Long subjectId) {
		this.subjectId = subjectId;
	}
	public Long getContactId() {
		return this.contactId;
	}
	public void setContactId(Long contactId) {
		this.contactId = contactId;
	}
	public String getRelation() {
		return this.relation;
	}
	public void setRelation(String relation) {
		this.relation = relation;
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof ContactsSubjectPK)) {
			return false;
		}
		ContactsSubjectPK castOther = (ContactsSubjectPK)other;
		return 
			this.subjectId.equals(castOther.subjectId)
			&& this.contactId.equals(castOther.contactId)
			&& this.relation.equals(castOther.relation);

    }
    
	public int hashCode() {
		final int prime = 31;
		int hash = 17;
		hash = hash * prime + this.subjectId.hashCode();
		hash = hash * prime + this.contactId.hashCode();
		hash = hash * prime + this.relation.hashCode();
		
		return hash;
    }
}